const data = {
    user_name: 'name1',
    user_id: 1000,
    detail: {
        user_avatar_url: 'xxx',
        object_one: {
            a_num: 1,
            str: 'str1',
        },
        array_one: [
            [
                {
                    a_num: 111,
                    b_num: 222,
                }
            ],
            [
                {
                    c_obj: {
                        c_num: 333,
                        str: 'str3',
                    }
                }
            ]
        ],
    },
};


function arr(iarr) {
    for (let [i, item] of iarr.entries()) {
        if (Array.isArray(item)) {
            arr(item)
        } else if (Object.prototype.toString.call(item) === "[object Object]") {
            obj(item)
        }
    }
}

function toUpper(str) {
    if (str.indexOf('_') > -1) {
        let splitStr = str.split('_')
        let result = ''
        for (let [i, item] of splitStr.entries()) {
            if (i > 0) {
                item = item.substring(0, 1).toLocaleUpperCase() + item.substring(1)
            }
            result += item
        }
        return result
    } else {
        return str
    }
}

function obj(iobj) {
    for (let [key, value] of Object.entries(iobj)) {//遍历对象
        let temp = toUpper(key)
        console.log(temp)
        delete iobj[key]
        iobj[temp] = value
        if (Array.isArray(value)) {
            arr(value)
        } else if (Object.prototype.toString.call(value) === "[object Object]") {
            obj(value)
        }
    }
}

obj(data)
console.log(data)


